﻿using System.ComponentModel;
using System.Web.Services;
using TripLOA.WebService.Serializable;
using TripLOA.WebService.Wrappers;
using System.Collections.Generic;

namespace TripLOA.WebService.Soap
{
    /// <summary>
    /// Summary description for SoapMessage
    /// </summary>
    [WebService(Namespace = "http://triploa.cli.di.unipi.it/service/soap/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class SoapMessage : System.Web.Services.WebService
    {
        private MessageCore core;

        public SoapMessage()
        {
            core = MessageCore.Instance();
        }

        [WebMethod(EnableSession=true)]
        public WSMessage GetSentMessages(string authToken, int start, int max)
        {
            return core.GetSentMessages(authToken, start, max);
        }

        [WebMethod(EnableSession=true)]
        public WSBool DeleteMessage(string authToken, int messageId)
        {
            return core.DeleteMessage(authToken, messageId);
        }

        [WebMethod(EnableSession=true)]
        public WSBool SendMessage(string authToken, Message msg, List<string> receivers)
        {
            return core.SendMessage(authToken, msg, receivers);
        }

        [WebMethod(EnableSession=true)]
        public WSBool MarkMessageAsRead(string authToken, int messageId)
        {
            return core.MarkMessageAsRead(authToken, messageId);
        }

        [WebMethod(EnableSession=true)]
        public WSMessage GetReceivedMessages(string authToken, int start, int max)
        {
            return core.GetReceivedMessages(authToken, start, max);
        }

        [WebMethod(EnableSession=true)]
        public WSMessage GetUnreadMessages(string authToken)
        {
            return core.GetUnreadMessages(authToken);
        }
    }
}
